import { Component, OnInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
    constructor(private translate: TranslateService) {
    }

    ngOnInit() {
        this.translate.addLangs(['en', 'fr', 'ur', 'es', 'it', 'fa', 'de','zh']);
        this.translate.setDefaultLang('en');
        let browserLang = this.translate.getBrowserLang();
        console.log(browserLang);
        this.translate.use(browserLang.match(/zh|fr|ur|es|it|fa|de/) ? browserLang : 'en');
        // this.changeLang('zh-CHS');
    }

    changeLang(language: string) {
        this.translate.use(language);
    }


}
